import time

from django.core.management.base import BaseCommand
from service.shedule_optimisation.optimiser import Optimiser
from service.models import Month, Event, PredictionFact
from django.core.management import call_command
from service.fill_service_data_from_xlsx import get_data_from_xlsx
from service.prediction_service import PredictionService
from users import models
from datetime import datetime
from random import randint


class Command(BaseCommand):
    help = 'Import users from Excel file'

    def handle(self, *args, **kwargs):
        for prediction_fact in PredictionFact.objects.filter(week=9, month_id=27):
            print(prediction_fact)
            PredictionFact.objects.create(
                specialization=prediction_fact.specialization,
                week = prediction_fact.week,
                qtty = prediction_fact.qtty/7*4 if prediction_fact.qtty else None,
                qtty_predicted = prediction_fact.qtty_predicted/7*4 if prediction_fact.qtty_predicted else None,
                month = Month.objects.get(id=27)
            )
            prediction_fact.qtty_predicted = prediction_fact.qtty_predicted/7*4 if prediction_fact.qtty_predicted else None
            prediction_fact.qtty = prediction_fact.qtty/7*4 if prediction_fact.qtty else None
            prediction_fact.save()

